import Print from '/@/utils/print'
import { useMessage } from '/@/hooks/web/useMessage'
const { createMessage: msg } = useMessage()
import { ref } from 'vue'
export async function usePrint() {
	const printInstance = ref({})
	printInstance.value = initPrint()

	let nowPrint = (arr) => {
		if (printInstance.value.status) {
			printInstance.value.sendPrint(arr)
		} else {
			msg.error('请先连接打印机！')
		}
	}
	let stop = printInstance.value.stop
	return {
		nowPrint,
		stop
	}
}

async function initPrint() {
	let res = await Print.init()
	return res
}
